package phoenics.manpads.common.mybatis.page.dialect;

import phoenics.manpads.common.mybatis.page.Dialect;

/**
 * oracle 方言
 *
 * @author Phoenics Chow
 * on 2018年12月10日
 */
public class OracleDialect implements Dialect {
    private static org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(OracleDialect.class);

    @Override
    public String buildPaginationSql(String originalSql, long offset, long limit) {
        limit = (offset >= 1) ? (offset + limit) : limit;
        return "SELECT * FROM ( SELECT TMP.*, ROWNUM ROW_ID FROM ( " +
                originalSql + " ) TMP WHERE ROWNUM <=" + limit + ") WHERE ROW_ID > " + offset;
    }
}
